package com.zhongwang.business.module.baseCostManage.controller;

import com.zhongwang.business.base.BaseController;
import com.zhongwang.business.common.JsonResult;
import com.zhongwang.business.module.baseCostManage.model.ProjectCostModel;
import com.zhongwang.business.module.baseCostManage.service.ProjectCostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ProjectCostController  extends BaseController {
    @Autowired
    private ProjectCostService projectCostService;
    @GetMapping("/projectCostList")
    public String linkProjectCostList(){
        return "/baseCost/list/projectCostList";
    }

    /**
     * 计划单成本数据项目列表
     * @param model
     * @return
     */
    @ResponseBody
    @PostMapping("/baseCost/projectCostList")
    public JsonResult selectList(ProjectCostModel model) {
//        startPage();
        return jsonResult(projectCostService.selectProjectCostList(model));
    }

    /**
     * 成本计划单数据的详细页面
     * @return
     */
    @GetMapping("/costDetailBoard")
    public String linkCostDetailBoard(@RequestParam("id") Integer id,
                                      @RequestParam("code") String code,
                                      @RequestParam("projectClassify") Integer projectClassify,
                                      @RequestParam("kind") Integer kind,
                                      @RequestParam("designType") Integer designType,
                                      Model model) {

//        @RequestParam("name") String name,
//                                      @RequestParam("num") Integer num,
//                                      @RequestParam("demander") String demander,
//                                      @RequestParam("address") String address,

        String name="";
        String demander="";
        String address="";
Integer num=0;
//        ProjectCostModel modelPar
        model.addAttribute("id",id);
        model.addAttribute("code",code);
        model.addAttribute("name",name);
        model.addAttribute("num",num);
        model.addAttribute("demander",demander);
        model.addAttribute("address",address);
        model.addAttribute("projectClassify",projectClassify == 1 ? "设计" : "非设计");

        model.addAttribute("kind",kind);
        model.addAttribute("designType",designType);

//        model.addAttribute("id",modelPar.getId());
//        model.addAttribute("code",modelPar.getCode());
//        model.addAttribute("name",modelPar.getName());
//        model.addAttribute("num",modelPar.getNum());
//        model.addAttribute("demander",modelPar.getDemander());
//        model.addAttribute("address",modelPar.getAddress());
//        if(modelPar.getProjectClassify()!=null) {
//            model.addAttribute("projectClassify", modelPar.getProjectClassify() == 1 ? "设计" : "非设计");
//        }else {
//            model.addAttribute("projectClassify","");
//        }
//        model.addAttribute("kind",modelPar.getKind());
//        model.addAttribute("designType",modelPar.getDesignType());

//        model.addAttribute("parameterModel",modelPar);
        return "/baseCost/list/costDetailBoard";
    }
    /**
     * 计划单成本数据项目列表
     * @param model
     * @return
     */
    @ResponseBody
    @PostMapping("/baseCost/costSubList")
    public JsonResult selectCostSubList(ProjectCostModel model) {
//        startPage();
        //****
        /**
         * 目前没有技术文件的产品结构表，商务的临时表，以满足开发需要！
         */
//     model.setId(3358);
        //****
        return jsonResult(projectCostService.selectCostSubList(model));
    }

    /**
     * 确认单页面
     * @return
     */
    @GetMapping("/projectCostRealityList")
    public String linkProjectCostRealityList(){
        return "/baseCost/list/projectCostRealityList";
    }

    /**
     * 确认单成本数据项目列表
     * @param model
     * @return
     */
    @ResponseBody
    @PostMapping("/baseCost/projectCostOKList")
    public JsonResult selProjectCostOKList(ProjectCostModel model) {
        startPage();
        return jsonResult(projectCostService.selectProjectCostHSList(model));
    }
}
